package cn.iocoder.yudao.module.trade.controller.app.followmerchant;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.trade.service.followmerchant.FollowMerchantService;
import io.swagger.v3.oas.annotations.media.Schema;
import org.mapstruct.ap.internal.util.Collections;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @author 梁富贵
 * @Date 2024/10/17
 **/
@Schema(description = "用户前台 - 关注商家")
@RestController
@RequestMapping("/user/follow-merchnat")
@Validated
public class FollowMerchantController {

    @Resource
    private FollowMerchantService followMerchantService;

    @Schema(description = "是否关注商家")
    @PostMapping("/follow")
    public CommonResult<Boolean> isFollow(Long merchantId) {
        return success(followMerchantService.isFollow(merchantId));
    }

    @Schema(description = "取消关注商家")
    @DeleteMapping("/unfollow")
    public CommonResult<Boolean> unFollow(@RequestParam("merchantIds") Long[] merchantIds) {
        return success(followMerchantService.unFollow(Arrays.asList(merchantIds)));
    }
}
